package cn.wolfcode.wolf2w.job;

import cn.wolfcode.wolf2w.domain.Strategy;
import cn.wolfcode.wolf2w.redis.service.IStrategyRedisService;
import cn.wolfcode.wolf2w.redis.vo.StrategyStatisVO;
import cn.wolfcode.wolf2w.service.IStrategyService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.scheduling.annotation.Scheduled;
import org.springframework.stereotype.Component;

import java.util.List;
//@Component
public class RedisDatePersistenceJob {

    @Autowired
    private IStrategyRedisService strategyRedisService;
    @Autowired
    private IStrategyService strategyService ;

   //cron表达式 任务计划
    @Scheduled(cron = "0/5 * * * * ? ") //定时任务标签
    public void doWork(){
        System.out.println("数据持久化开始--------------------");
        //获取redis中所有的vo对象
        List<StrategyStatisVO> vos =  strategyRedisService.getStaregyVos();

        //遍历vo对象 ,执行攻略统计数据更新
        for (StrategyStatisVO vo : vos) {
            strategyService.updateStatisVo(vo);
        }
        System.out.println("数据持久化结束--------------------");
    }
}
